package com.zmx.doctor.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.zmx.doctor.R;
import com.zmx.doctor.fragment.TwoFragment;
import com.zmx.doctor.pojo.GoodsClassification;
import com.zmx.doctor.view.activity.GoodsDetailsActivity;
import com.zmx.doctor.view.activity.GoodsItemActivity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 程序猿：胖胖祥
 * 时 间：2020/12/18  17:08
 * 功 能：
 */

public class GoodsClassificationAdapter extends BaseAdapterRvList<GoodsClassificationAdapter.ViewHolder, GoodsClassification> {


    public GoodsClassificationAdapter(Activity activity) {
        super(activity);
    }

    @Override
    protected void onBindVH(ViewHolder holder, int listPosition, GoodsClassification g) {


        Glide.with(mActivity).load(g.getIcon()).into(holder.titleview);
        holder.title.setText(g.getName());
        holder.linear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(mActivity, GoodsItemActivity.class);
                intent.putExtra("id", g.getId() + "");
                mActivity.startActivity(intent);

            }
        });

    }

    @NonNull
    @Override
    protected ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {

        GoodsClassificationAdapter.ViewHolder holder = new GoodsClassificationAdapter.ViewHolder(inflater.inflate(R.layout.adapter_goods_classification, parent, false));
        return holder;

    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.image)
        ImageView titleview;
        @BindView(R.id.name)
        TextView title;
        @BindView(R.id.linear)
        LinearLayout linear;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
